/*
 * @Author: wang cong wangc9832@163.com
 * @Date: 2023-10-20 14:36:32
 * @LastEditors: wang cong wangc9832@163.com
 * @LastEditTime: 2023-11-21 09:39:09
 * @FilePath: /ams_product_front/src/api/finance/amsVoucherTemplateManage.ts
 * @Description:
 *
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
 */
import { BasicFetchResult } from '../model/baseModel';
import { defHttp } from '@/utils/http/axios';
import { downloadBlob } from '@/utils/file/download';
const api = '/amsVoucherTemplate';
// 启用
export const enable = (params?: any) =>
  defHttp.post({ url: api + '/enable', params });
// 关闭
export const disable = (params?: any) =>
  defHttp.post({ url: api + '/disable', params });
// 详情
export const detail = (params: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: `${api}/detail`, params });
/**
 * 分页查询
 * @author flc
 * @date 2023-10-19 10:19:24
 */
export const page = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: api + '/page', params });
/**
 * 不分页查询
 * @author flc
 * @date 2023-10-19 10:19:24
 */
export const list = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: api + '/list', params });
/**
 * 新增
 * @author flc
 * @date 2023-10-19 10:19:24
 */
export const add = (params?: any) =>
  defHttp.post({ url: api + '/add', params });
/**
 * 修改
 * @author flc
 * @date 2023-10-19 10:19:24
 */
export const edit = (params?: any) =>
  defHttp.post({ url: api + '/edit', params });

/**
 * 删除
 * @author flc
 * @date 2023-10-19 10:19:24
 */
export const del = (ids: string[]) =>
  defHttp.post({ url: api + '/delete', params: ids });
/**
 * 导出
 * @author flc
 * @date 2023-10-19 10:19:24
 */
export const exp = (params?: any) => {
  return new Promise<void>((resolve, reject) => {
    defHttp
      .get(
        { responseType: 'blob', url: api + '/export', params },
        { isReturnNativeResponse: true }
      )
      .then((res) => {
        downloadBlob(res);
        resolve();
      })
      .catch(() => {
        reject();
      });
  });
};
